<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>
        日志
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../../css/main.css" media="all">
    <script type="text/javascript" src="../../../lib/loading/okLoading.js"></script>
    <link rel="stylesheet" href="../../../css/bootstrap.css">
    <link rel="stylesheet" href="../../../lib/layui/css/layui_2.5.7.css">
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .layui-table-page select {
            height: 22px;
        }
    </style>
</head>

<body>
<div>
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a><cite>首页</cite></a>
            <a><cite>通用</cite></a>
            <a><cite>日志</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
           href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon"
                                                                            style="line-height:30px">ဂ</i></a>
    </div>

    <div class="main_box">
        <div class="panel-heading">
            <ul class="nav nav-tabs" id="navTabs">
                <li class="all"><a href="logs_list.html?type=all">全部</a></li>
                <li class="cw"><a href="logs_list.html?type=cw">财务</a></li>
                <li class="xa"><a href="logs_list.html?type=xa">销安</a></li>
                <li class="wb"><a href="logs_list.html?type=wb">维保</a></li>
                <li class="kf"><a href="logs_list.html?type=kf">库房</a></li>
                <li class="ty"><a href="logs_list.html?type=ty">通用</a></li>
            </ul>
        </div>
    </div>

    <form class="layui-form x-center">
        <div class="layui-form-pane" style="margin-top: 15px;">
            <div class="layui-form-item" style="padding-left: 7%">
                <label class="layui-form-label">操作内容</label>
                <div class="layui-input-inline">
                    <input  autocomplete="off" type="text" class="layui-input" name="operationName" placeholder="操作内容">
                </div>
                <label class="layui-form-label">添加时间</label>
                <div class="layui-input-inline">
                    <input  autocomplete="off" class="layui-input" placeholder="开始日" name="start" id="start">
                </div>
                <div class="layui-input-inline">
                    <input  autocomplete="off" class="layui-input" placeholder="截止日" name="end" id="end">
                </div>
                <div class="layui-input-inline layui-show-xs-block">
                    <button class="layui-btn" type="button" lay-filter="sreach" data-type="reload"
                            onclick="reload()">
                        <i class="layui-icon">&#xe615;</i></button>
                </div>
            </div>
        </div>
    </form>


    <div class="layui-card-body">

        <table class="layui-table" id="test" lay-filter="test">
        </table>
    </div>
    <br><br><br><br><br><br><br>
</div>
</body>


<script type="text/javascript" src="../../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../../js/myAjax.js"></script>
<script type="text/javascript" src="../../../js/pub.js"></script>
<script type="text/javascript" src="../../../lib/layui/layui2.5.7.js"></script>
<script type="text/javascript" src="../../../js/vue.min.js"></script>
<!-- <script src="lib/layui/layui.js" charset="utf-8"></script> -->
<script src="../../../js/x-layui.js" charset="utf-8"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script>
    layui.use(['laydate', 'element', 'laypage', 'layer', 'form'], function () {
        $ = layui.jquery;//jquery
        laydate = layui.laydate;//日期插件
        lement = layui.element;//面包导航
        laypage = layui.laypage;//分页
        layer = layui.layer;//弹出层
        var form = layui.form;
        okLoading.close($);
    });
</script>

<script>

    var type = getQueryVariable("type");
    $('#navTabs li').removeClass("active");
    $('.' + type).addClass("active");


    layui.use(['laydate', 'form'],
        function () {
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                trigger: 'click',
                type: 'datetime',
                elem: '#start' //指定元素
            });

            //执行一个laydate实例
            laydate.render({
                trigger: 'click',
                type: 'datetime',
                elem: '#end' //指定元素
            });
        });
    let t;
    if(type==='cw'){
        t = '财务'
    }else if(type === 'xa'){
        t = '销安'
    }else if(type === 'wb'){
        t = '维保'
    }else if(type === 'kf'){
        t = '库房'
    }else if(type === 'ty'){
        t = '通用'
    }

    layui.use('table', function () {
        table = layui.table;
        //方法级渲染
        var t1 = table.render({
            elem: '#test',
            url: $baseUrl + 'logs/findLogsList',
            where: {
                userId: $userId,
                type: t,
            },
            headers: {
                token: $token
            },
            // toolbar: true,
            cols: [
                [{
                    field: 'type',
                    title: '类型',
                    fixed: 'left',
                    templet(item) {
                        return '<span style="color: cornflowerblue">' + item.type + '</span>'
                    },
                    width: '8%'
                },
                    {
                        field: 'userName',
                        title: '用户名称',
                        width: '12%'
                    },
                    {
                        field: 'operationTime',
                        title: '操作时间',
                    },
                    {
                        field: 'operationName',
                        title: '操作内容',
                        width: '15%'
                    },
                    // {
                    //     field: 'operationUrl',
                    //     title: '操作地址',
                    // },
                    // {
                    //     field: 'sendParams',
                    //     title: '发送数据',
                    // },
                    {
                        field: 'createTime',
                        title: '创建时间',
                    },
                ]
            ],
            request: {
                pageName: 'pageNum', //页码的参数名称，默认：page
                limitName: 'pageSize',
            },
            response: {
                statusName: 'code' //规定数据状态的字段名称，默认：code
                ,
                statusCode: 0 //规定成功的状态码，默认：0
                ,
                msgName: 'msg' //规定状态信息的字段名称，默认：msg
                ,
                countName: 'total' //规定数据总数的字段名称，默认：count
                ,
                dataName: 'data', //规定数据列表的字段名称，默认：data
            },
            id: 'test',
            page: true,
            height: 'auto',
            even: true,
            done: function (res, curr, count) {
                //是否有权限或权限是否失效
                authorizeState();
                console.log(res);
            }
        });
    });

    function reload(value) {
        table.reload('test', {
            where: {
                operationName: $("input[name=operationName]").val(),
                start: $("input[name=start]").val(),
                end: $("input[name=end]").val(),
            }
        });
    }

</script>
</html>
